import 'package:awak/common/models/user.dart';
import 'package:awak/common/models/room.dart';
import 'package:awak/common/models/comment.dart';
import 'package:awak/common/models/topic.dart';
import 'package:awak/common/models/content.dart';
import 'package:awak/common/models/review.dart';
import 'package:awak/common/models/chat.dart';
import 'package:awak/common/models/plan.dart';
import 'package:awak/common/models/today_goal.dart';

abstract class AwakState {}

class AwakInitial extends AwakState {}

class AwakLoading extends AwakState {}

class AwakSuccess extends AwakState {
  final User user;
  AwakSuccess(this.user);
}

class AwakFailure extends AwakState {
  final String message;
  AwakFailure(this.message);
}

// 房间加载中
class RoomLoading extends AwakState {}
// 房间操作成功
class RoomSuccess extends AwakState {
  final Room room;
  RoomSuccess(this.room);
}
// 房间操作失败
class RoomFailure extends AwakState {
  final String message;
  RoomFailure(this.message);
}
// 房间列表成功
class RoomsLoaded extends AwakState {
  final List<Room> rooms;
  final User? currentUser;
  final List<Topic>? topics; // 添加topics字段
  RoomsLoaded(this.rooms, {this.currentUser, this.topics});
}

// 评论加载中
class CommentLoading extends AwakState {}

// 评论操作成功
class CommentSuccess extends AwakState {
  final Comment comment;
  CommentSuccess(this.comment);
}

// 评论操作失败
class CommentFailure extends AwakState {
  final String message;
  CommentFailure(this.message);
}

// 主题加载中
class TopicLoading extends AwakState {}

// 主题加载成功
class TopicsLoaded extends AwakState {
  final List<Topic> topics;
  final User? currentUser;
  final List<Room>? rooms; // 添加rooms字段
  TopicsLoaded(this.topics, {this.currentUser, this.rooms});
}

// 单个主题加载成功
class TopicLoaded extends AwakState {
  final Topic? topic;
  final User? currentUser;
  TopicLoaded(this.topic, {this.currentUser});
}

// 主题操作成功
class TopicSuccess extends AwakState {
  final Topic topic;
  TopicSuccess(this.topic);
}

// 主题操作失败
class TopicFailure extends AwakState {
  final String message;
  TopicFailure(this.message);
}

// 内容加载中
class ContentLoading extends AwakState {}

// 内容加载成功
class ContentsLoaded extends AwakState {
  final List<Content> contents;
  final User? currentUser;
  ContentsLoaded(this.contents, {this.currentUser});
}

// 内容操作成功
class ContentSuccess extends AwakState {
  final Content content;
  ContentSuccess(this.content);
}

// 内容操作失败
class ContentFailure extends AwakState {
  final String message;
  ContentFailure(this.message);
}

// 评论列表成功
class CommentsLoaded extends AwakState {
  final List<Comment> comments;
  final User? currentUser;
  CommentsLoaded(this.comments, {this.currentUser});
}

// Review相关状态
// Review加载中
class ReviewLoading extends AwakState {}

// Review列表成功
class ReviewsLoaded extends AwakState {
  final List<Review> reviews;
  final User? currentUser;
  ReviewsLoaded(this.reviews, {this.currentUser});
}

// Review操作成功
class ReviewSuccess extends AwakState {
  final Review review;
  ReviewSuccess(this.review);
}

// Review操作失败
class ReviewFailure extends AwakState {
  final String message;
  ReviewFailure(this.message);
}

// Review已添加
class ReviewAdded extends AwakState {
  final Review review;
  ReviewAdded(this.review);
}

// Review已更新
class ReviewUpdated extends AwakState {
  final Review review;
  ReviewUpdated(this.review);
}

// Review已删除
class ReviewDeleted extends AwakState {
  final int reviewId;
  ReviewDeleted(this.reviewId);
}

// 聊天加载中
class ChatLoading extends AwakState {}

// 聊天消息已加载
class ChatMessagesLoaded extends AwakState {
  final List<Chat> messages;
  final User? currentUser;
  final User? otherUser;

  ChatMessagesLoaded(this.messages, {this.currentUser, this.otherUser});
}

// 聊天消息已发送
class ChatMessageSent extends AwakState {
  final Chat message;

  ChatMessageSent(this.message);
}

// 聊天消息已删除
class ChatMessageDeleted extends AwakState {
  final int chatId;

  ChatMessageDeleted(this.chatId);
}

// 聊天记录已清空
class ChatCleared extends AwakState {}

// 聊天失败
class ChatFailure extends AwakState {
  final String message;

  ChatFailure(this.message);
}

// 好友加载中
class FriendshipLoading extends AwakState {}

// 好友已添加
class FriendAdded extends AwakState {
  final String message;

  FriendAdded(this.message);
}

// 好友已删除
class FriendRemoved extends AwakState {
  final String message;

  FriendRemoved(this.message);
}

// 好友列表已加载
class FriendsLoaded extends AwakState {
  final List<User> friends;
  final User? currentUser;

  FriendsLoaded(this.friends, {this.currentUser});
}

// 好友关系检查结果
class FriendshipChecked extends AwakState {
  final bool isFriend;

  FriendshipChecked(this.isFriend);
}

// 好友操作失败
class FriendshipFailure extends AwakState {
  final String message;

  FriendshipFailure(this.message);
}

// 计划加载中
class PlanLoading extends AwakState {}

// 计划已创建
class PlanCreated extends AwakState {
  final Plan plan;

  PlanCreated(this.plan);
}

// 计划列表已加载
class PlansLoaded extends AwakState {
  final List<Plan> plans;

  PlansLoaded(this.plans);
}

// 今天未完成的计划已加载
class TodayUncompletedPlansLoaded extends AwakState {
  final List<Plan> plans;

  TodayUncompletedPlansLoaded(this.plans);
}

// 本周计划已加载
class ThisWeekPlansLoaded extends AwakState {
  final List<Plan> plans;

  ThisWeekPlansLoaded(this.plans);
}

// 未开始的计划已加载
class NotStartedPlansLoaded extends AwakState {
  final List<Plan> plans;

  NotStartedPlansLoaded(this.plans);
}

// 过去30天的历史计划已加载
class Last30DaysPlansLoaded extends AwakState {
  final List<Plan> plans;

  Last30DaysPlansLoaded(this.plans);
}

// 计划状态已更新
class PlanStateUpdated extends AwakState {
  final int planId;
  final String state;

  PlanStateUpdated(this.planId, this.state);
}

// 计划时间已更新
class PlanTimeUpdated extends AwakState {
  final Plan plan;

  PlanTimeUpdated(this.plan);
}

// 超时计划已更新
class ExpiredPlansUpdated extends AwakState {}

// 计划已删除
class PlanDeleted extends AwakState {
  final int planId;

  PlanDeleted(this.planId);
}

// 计划操作失败
class PlanFailure extends AwakState {
  final String message;

  PlanFailure(this.message);
}

// 今日目标加载中
class TodayGoalLoading extends AwakState {}

// 今日目标已创建
class TodayGoalCreated extends AwakState {
  final TodayGoal todayGoal;

  TodayGoalCreated(this.todayGoal);
}

// 今日目标列表已加载
class TodayGoalsLoaded extends AwakState {
  final List<TodayGoal> todayGoals;

  TodayGoalsLoaded(this.todayGoals);
}

// 今日目标已删除
class TodayGoalDeleted extends AwakState {
  final int goalId;

  TodayGoalDeleted(this.goalId);
}

// 今日目标批量删除完成
class TodayGoalsBatchDeleted extends AwakState {
  final List<int> goalIds;

  TodayGoalsBatchDeleted(this.goalIds);
}

// 今日目标操作失败
class TodayGoalFailure extends AwakState {
  final String message;

  TodayGoalFailure(this.message);
}